﻿<%@ page import="java.util.*" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<%
	String Code = (String)session.getAttribute("LanguageCode");
	String SubCode = (String)session.getAttribute("LanguageSubcode");
    Locale locale = new Locale(Code, SubCode);
	ResourceBundle resource = ResourceBundle.getBundle("resource", locale);
%>
<style>

</style>
<script>
sequenceOnload.push(fillDialogCalendar);

function fillDialogCalendar(){
	
	$(".datepicker").datepicker({
        changeMonth: true,
        changeYear: true,
        monthNamesShort: ShortMonth,
		monthNames: ShortMonth,
		dayNamesShort: ShortDay,
		dayNames: ShortDay,
		dateFormat: SharedData.General.dateFormat.dateTimeFormat,
        onSelect: function(dateText) {
			
        	$('.pageheader').get(0).change.val($(".datepicker").val());
			$('.pageheader').get(0).change.text($(".datepicker").val());
        	close_table($(".datepicker").val());
        }
    });
}
function on_focus(dom){
	dom.css("color","#9999FF");
	dom.css("cursor","pointer");
}
function on_blur(dom){
	dom.css("color","#330099");
	dom.css("cursor","pointer");
}
function fillQuickDate(){
	var min = $(".datepicker").datepicker("option", "minDate");
	var max = $(".datepicker").datepicker("option", "maxDate");
	
	var now = getDate();
	var d = '';
	var added = 0;
	if(now >= min) if(max==null || now<=max) d+='<span class="quickDateItem" value="'+now+'" onclick="quickdate(new Date($(this).attr(\'value\')));" >' + ShortDay[now.getDay()] + ' ' + now.getFormatedString() + '&nbsp;<'+Calendar_Today+'> </span><br>';
	added = 1;
	if(now.addDate(added) >= min)  if(max==null || now.addDate(added)<= max) d+='<span class="quickDateItem" value="'+now.addDate(added)+'" onclick="quickdate(new Date($(this).attr(\'value\')));" >' + ShortDay[now.addDate(added).getDay()] + ' ' + now.addDate(added).getFormatedString() + '&nbsp;<'+Calendar_Tomorrow+'> </span><br>';
	added = 2;
	if(now.addDate(added) >= min)  if(max==null || now.addDate(added)<= max) d+='<span class="quickDateItem" value="'+now.addDate(added)+'" onclick="quickdate(new Date($(this).attr(\'value\')));" >' + ShortDay[now.addDate(added).getDay()] + ' ' + now.addDate(added).getFormatedString() + ' </span><br>';
	added = 3;
	if(now.addDate(added) >= min)  if(max==null || now.addDate(added)<= max) d+='<span class="quickDateItem" value="'+now.addDate(added)+'" onclick="quickdate(new Date($(this).attr(\'value\')));" >' + ShortDay[now.addDate(added).getDay()] + ' ' + now.addDate(added).getFormatedString() + ' </span><br>';
	added = 4;
	if(now.addDate(added) >= min)  if(max==null || now.addDate(added)<= max) d+='<span class="quickDateItem" value="'+now.addDate(added)+'" onclick="quickdate(new Date($(this).attr(\'value\')));" >' + ShortDay[now.addDate(added).getDay()] + ' ' + now.addDate(added).getFormatedString() + ' </span><br>';
	added = 7;
	if(now.addDate(added) >= min)  if(max==null || now.addDate(added)<= max) d+='<span class="quickDateItem" value="'+now.addDate(added)+'" onclick="quickdate(new Date($(this).attr(\'value\')));" >' + ShortDay[now.addDate(added).getDay()] + ' ' + now.addDate(added).getFormatedString() + ' </span><br>';
	added = 14;
	if(now.addDate(added) >= min)  if(max==null || now.addDate(added)<= max) d+='<span class="quickDateItem" value="'+now.addDate(added)+'" onclick="quickdate(new Date($(this).attr(\'value\')));" >' + ShortDay[now.addDate(added).getDay()] + ' ' + now.addDate(added).getFormatedString() + ' </span><br>';
	added = 21;
	if(now.addDate(added) >= min)  if(max==null || now.addDate(added)<= max) d+='<span class="quickDateItem" value="'+now.addDate(added)+'" onclick="quickdate(new Date($(this).attr(\'value\')));" >' + ShortDay[now.addDate(added).getDay()] + ' ' + now.addDate(added).getFormatedString() + ' </span><br>';
	
	$(".QuickDate").html(d);
}
function close_table(val){
   	$( ".pageheader" ).css("display","none");
	$('.pageheader').get(0).change.select();
	var callback = $('.pageheader').get(0).callback;
	if(val == null)
		val = $('.pageheader').get(0).change.val();
	
	if(callback != null)
		callback(val);
}
function quickdate(date){
	$('.pageheader').get(0).change.val(date.getFormatedString());
	close_table(date.getFormatedString());
}
</script>

<div class="pageheader" style="display:none; position:absolute;">
  <table width="470" border="0" style="background:white;">
    <tr style=" border-top:#CCC solid 1px;   border-left:#CCC solid 1px; border-right:#CCC solid 1px;">
      <td width="74" style="text-align:center;">Due Date </td>
      <td width="152"><label>
        <input type="text" name="textfield" class="datepickerShow" />
      </label></td>
      <td width="222"><label>
        <input type="text" name="textfield2" class="timepicker9" />
      </label></td>
      <td><button onclick="close_table()" class="button_close"><img src="/images/components/task/x.jpg" alt="" width="30px;" height="30px;"></button></td>
    </tr>
    <tr style=" border-bottom:#CCC solid 1px;  border-left:#CCC solid 1px; border-right:#CCC solid 1px;  border-top:#CCC solid 1px; vertical-align:top;">
      <td colspan="2">
<div class="datepicker"></div>
	  </td>
      <td colspan="2"><table>
          <tr>
            <td><h1>Quick Date</h1></td>
          </tr>
          <tr>
            <td><div style="margin-top:0px;"><span class="QuickDate" ></span></div></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
          </tr>
      </table></td>
    </tr>
  </table>
</div>
